<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dynamic Loading of Modules</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-core.html" title="GLib Core Application Support">
<link rel="prev" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues">
<link rel="next" href="glib-Memory-Allocation.html" title="Memory Allocation">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Asynchronous-Queues.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-core.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Memory-Allocation.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Dynamic-Loading-of-Modules.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Dynamic-Loading-of-Modules.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-Dynamic-Loading-of-Modules"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Dynamic-Loading-of-Modules.top_of_page"></a>Dynamic Loading of Modules</span></h2>
<p>Dynamic Loading of Modules — portable method for dynamically loading 'plug-ins'</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-Dynamic-Loading-of-Modules.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gmodule.h&gt;

                    <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule">GModule</a>;
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-supported" title="g_module_supported ()">g_module_supported</a>                  (<em class="parameter"><code><span class="type">void</span></code></em>);
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *                 <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-build-path" title="g_module_build_path ()">g_module_build_path</a>             (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *directory</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *module_name</code></em>);
#define             <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-open" title="g_module_open">g_module_open</a>
enum                <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModuleFlags" title="enum GModuleFlags">GModuleFlags</a>;
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-symbol" title="g_module_symbol ()">g_module_symbol</a>                     (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *symbol_name</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> *symbol</code></em>);
#define             <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-name" title="g_module_name">g_module_name</a>
<span class="returnvalue">void</span>                <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-make-resident" title="g_module_make_resident ()">g_module_make_resident</a>              (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-close" title="g_module_close ()">g_module_close</a>                      (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);
const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *          <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-error" title="g_module_error ()">g_module_error</a>                   (<em class="parameter"><code><span class="type">void</span></code></em>);

const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       (<a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModuleCheckInit" title="GModuleCheckInit ()">*GModuleCheckInit</a>)                 (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);
<span class="returnvalue">void</span>                (<a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModuleUnload" title="GModuleUnload ()">*GModuleUnload</a>)                    (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);
#define             <a class="link" href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-SUFFIX:CAPS" title="G_MODULE_SUFFIX">G_MODULE_SUFFIX</a>
#define             <a class="link" href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-EXPORT:CAPS" title="G_MODULE_EXPORT">G_MODULE_EXPORT</a>
#define             <a class="link" href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-IMPORT:CAPS" title="G_MODULE_IMPORT">G_MODULE_IMPORT</a>
</pre>
</div>
<div class="refsect1">
<a name="glib-Dynamic-Loading-of-Modules.description"></a><h2>Description</h2>
<p>
These functions provide a portable way to dynamically load object files
(commonly known as 'plug-ins').
The current implementation supports all systems that provide
an implementation of <code class="function">dlopen()</code> (e.g. Linux/Sun), as well as HP-UX via its
<code class="function">shl_load()</code> mechanism, and Windows platforms via DLLs.
</p>
<p>
A program which wants to use these functions must be linked to the
libraries output by the command <span class="command"><strong>pkg-config --libs gmodule-2.0</strong></span>.
</p>
<p>
To use them you must first determine whether dynamic loading
is supported on the platform by calling <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-supported" title="g_module_supported ()"><code class="function">g_module_supported()</code></a>.
If it is, you can open a module with <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-open" title="g_module_open"><code class="function">g_module_open()</code></a>,
find the module's symbols (e.g. function names) with <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-symbol" title="g_module_symbol ()"><code class="function">g_module_symbol()</code></a>,
and later close the module with <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-close" title="g_module_close ()"><code class="function">g_module_close()</code></a>.
<a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-name" title="g_module_name"><code class="function">g_module_name()</code></a> will return the file name of a currently opened module.
</p>
<p>
If any of the above functions fail, the error status can be found with
<a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-error" title="g_module_error ()"><code class="function">g_module_error()</code></a>.
</p>
<p>
The <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> implementation features reference counting for opened modules,
and supports hook functions within a module which are called when the
module is loaded and unloaded (see <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModuleCheckInit" title="GModuleCheckInit ()"><span class="type">GModuleCheckInit</span></a> and <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModuleUnload" title="GModuleUnload ()"><span class="type">GModuleUnload</span></a>).
</p>
<p>
If your module introduces static data to common subsystems in the running
program, e.g. through calling <code class="literal">g_quark_from_static_string ("my-module-stuff")</code>,
it must ensure that it is never unloaded, by calling <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-make-resident" title="g_module_make_resident ()"><code class="function">g_module_make_resident()</code></a>.
</p>
<p>
</p>
<div class="example">
<a name="id385670"></a><p class="title"><b>Example 11. Calling a function defined in a <span class="structname">GModule</span></b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="comment">/* the function signature for 'say_hello' */</span>
<span class="keyword">typedef</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="symbol">(*</span><span class="normal"> SayHelloFunc</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">(</span><span class="keyword">const</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">message</span><span class="symbol">);</span>
<span class="normal"><a href="glib-Basic-Types.html#gboolean">gboolean</a></span>
<span class="function">just_say_hello</span><span class="normal"> </span><span class="symbol">(</span><span class="keyword">const</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">filename</span><span class="symbol">,</span><span class="normal"> </span><span class="usertype">GError</span><span class="normal"> </span><span class="symbol">**</span><span class="normal">error</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="usertype">SayHelloFunc</span><span class="normal">  say_hello</span><span class="symbol">;</span>
<span class="normal">  </span><span class="usertype">GModule</span><span class="normal">      </span><span class="symbol">*</span><span class="normal">module</span><span class="symbol">;</span>
<span class="normal">  module </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-open">g_module_open</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">filename</span><span class="symbol">,</span><span class="normal"> <a href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-BIND-LAZY:CAPS">G_MODULE_BIND_LAZY</a></span><span class="symbol">);</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="normal">module</span><span class="symbol">)</span>
<span class="normal">    </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="function"><a href="glib-Error-Reporting.html#g-set-error">g_set_error</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">error</span><span class="symbol">,</span><span class="normal"> FOO_ERROR</span><span class="symbol">,</span><span class="normal"> FOO_ERROR_BLAH</span><span class="symbol">,</span>
<span class="normal">           </span><span class="string">"%s"</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a></span><span class="normal"> </span><span class="symbol">());</span>
<span class="normal">      </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-symbol">g_module_symbol</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">module</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"say_hello"</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gpointer">gpointer</a> </span><span class="symbol">*)&amp;</span><span class="normal">say_hello</span><span class="symbol">))</span>
<span class="normal">    </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="function"><a href="glib-Error-Reporting.html#g-set-error">g_set_error</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">error</span><span class="symbol">,</span><span class="normal"> SAY_ERROR</span><span class="symbol">,</span><span class="normal"> SAY_ERROR_OPEN</span><span class="symbol">,</span>
<span class="normal">           </span><span class="string">"%s: %s"</span><span class="symbol">,</span><span class="normal"> filename</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a></span><span class="normal"> </span><span class="symbol">());</span>
<span class="normal">      </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-close">g_module_close</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">module</span><span class="symbol">))</span>
<span class="normal">    </span><span class="function"><a href="glib-Message-Logging.html#g-warning">g_warning</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"%s: %s"</span><span class="symbol">,</span><span class="normal"> filename</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a></span><span class="normal"> </span><span class="symbol">());</span>
<span class="normal">      </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">say_hello </span><span class="symbol">==</span><span class="normal"> <a href="glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">)</span>
<span class="normal">    </span><span class="cbracket">{</span>
<span class="normal">      </span><span class="function"><a href="glib-Error-Reporting.html#g-set-error">g_set_error</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">error</span><span class="symbol">,</span><span class="normal"> SAY_ERROR</span><span class="symbol">,</span><span class="normal"> SAY_ERROR_OPEN</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"symbol say_hello is NULL"</span><span class="symbol">);</span>
<span class="normal">      </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-close">g_module_close</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">module</span><span class="symbol">))</span>
<span class="normal">    </span><span class="function"><a href="glib-Message-Logging.html#g-warning">g_warning</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"%s: %s"</span><span class="symbol">,</span><span class="normal"> filename</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a></span><span class="normal"> </span><span class="symbol">());</span>
<span class="normal">      </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="normal">  </span><span class="comment">/* call our function in the module */</span>
<span class="normal">  </span><span class="function">say_hello</span><span class="normal"> </span><span class="symbol">(</span><span class="string">"Hello world!"</span><span class="symbol">);</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-close">g_module_close</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">module</span><span class="symbol">))</span>
<span class="normal">    </span><span class="function"><a href="glib-Message-Logging.html#g-warning">g_warning</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"%s: %s"</span><span class="symbol">,</span><span class="normal"> filename</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="glib-Dynamic-Loading-of-Modules.html#g-module-error">g_module_error</a></span><span class="normal"> </span><span class="symbol">());</span>
<span class="normal">  </span><span class="keyword">return</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">;</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1">
<a name="glib-Dynamic-Loading-of-Modules.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GModule"></a><h3>GModule</h3>
<pre class="programlisting">typedef struct _GModule GModule;</pre>
<p>
The <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> struct is an opaque data structure to represent a
<a class="link" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules">Dynamically-Loaded Module</a>.
It should only be accessed via the following functions.
</p>
</div>
<hr>
<div class="refsect2">
<a name="g-module-supported"></a><h3>g_module_supported ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_module_supported                  (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Checks if modules are supported on the current platform.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if modules are supported.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-build-path"></a><h3>g_module_build_path ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *                 g_module_build_path             (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *directory</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *module_name</code></em>);</pre>
<p>
A portable way to build the filename of a module. The platform-specific
prefix and suffix are added to the filename, if needed, and the result is
added to the directory, using the correct separator character.
</p>
<p>
The directory should specify the directory where the module can be found.
It can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> or an empty string to indicate that the module is in a standard
platform-specific directory, though this is not recommended since the
wrong module may be found.
</p>
<p>
For example, calling <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-build-path" title="g_module_build_path ()"><code class="function">g_module_build_path()</code></a> on a Linux system with a <em class="parameter"><code>directory</code></em>
of <code class="filename">/lib</code> and a <em class="parameter"><code>module_name</code></em> of "mylibrary" will return
<code class="filename">/lib/libmylibrary.so</code>. On a Windows system, using
<code class="filename">\Windows</code> as the directory it will return
<code class="filename">\Windows\mylibrary.dll</code>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>directory</code></em> :</span></p></td>
<td>the directory where the module is. This can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> or the empty
string to indicate that the standard platform-specific directories will be
used, though that is not recommended.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>module_name</code></em> :</span></p></td>
<td>the name of the module.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the complete path of the module, including the standard library
prefix and suffix. This should be freed when no longer needed.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-open"></a><h3>g_module_open</h3>
<pre class="programlisting">#define             g_module_open</pre>
<p>
Opens a module. If the module has already been opened, its reference
count is incremented.
</p>
<p>
First of all <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-open" title="g_module_open"><code class="function">g_module_open()</code></a> tries to open <em class="parameter"><code>file_name</code></em> as a module. If
that fails and <em class="parameter"><code>file_name</code></em> has the ".la"-suffix (and is a libtool archive)
it tries to open the corresponding module. If that fails and it doesn't
have the proper module suffix for the platform (<a class="link" href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-SUFFIX:CAPS" title="G_MODULE_SUFFIX"><span class="type">G_MODULE_SUFFIX</span></a>), this
suffix will be appended and the corresponding module will be opended. If
that fails and <em class="parameter"><code>file_name</code></em> doesn't have the ".la"-suffix, this suffix is
appended and <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-open" title="g_module_open"><code class="function">g_module_open()</code></a> tries to open the corresponding module. If
eventually that fails as well, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> on success, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> on failure.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GModuleFlags"></a><h3>enum GModuleFlags</h3>
<pre class="programlisting">typedef enum
{
  G_MODULE_BIND_LAZY = 1 &lt;&lt; 0,
  G_MODULE_BIND_LOCAL = 1 &lt;&lt; 1,
  G_MODULE_BIND_MASK = 0x03
} GModuleFlags;
</pre>
<p>
Flags passed to <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-open" title="g_module_open"><code class="function">g_module_open()</code></a>. Note that these flags are
not supported on all platforms.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><a name="G-MODULE-BIND-LAZY:CAPS"></a><span class="term"><code class="literal">G_MODULE_BIND_LAZY</code></span></p></td>
<td>specifies that symbols are only resolved when needed.
  The default action is to bind all symbols when the module is loaded.
</td>
</tr>
<tr>
<td><p><a name="G-MODULE-BIND-LOCAL:CAPS"></a><span class="term"><code class="literal">G_MODULE_BIND_LOCAL</code></span></p></td>
<td>specifies that symbols in the module should
  not be added to the global name space.  The default action on most
  platforms is to place symbols in the module in the global name space,
  which may cause conflicts with existing symbols.
</td>
</tr>
<tr>
<td><p><a name="G-MODULE-BIND-MASK:CAPS"></a><span class="term"><code class="literal">G_MODULE_BIND_MASK</code></span></p></td>
<td>mask for all flags.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-symbol"></a><h3>g_module_symbol ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_module_symbol                     (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>,
                                                         <em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *symbol_name</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> *symbol</code></em>);</pre>
<p>
Gets a symbol pointer from a module, such as one exported by <a class="link" href="glib-Dynamic-Loading-of-Modules.html#G-MODULE-EXPORT:CAPS" title="G_MODULE_EXPORT"><span class="type">G_MODULE_EXPORT</span></a>.
</p>
<p>
Note that a valid symbol can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>symbol_name</code></em> :</span></p></td>
<td>the name of the symbol to find.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>symbol</code></em> :</span></p></td>
<td>returns the pointer to the symbol value.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-name"></a><h3>g_module_name</h3>
<pre class="programlisting">#define             g_module_name</pre>
<p>
Gets the filename from a <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the filename of the module, or "main" if the module is the main
program itself.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-make-resident"></a><h3>g_module_make_resident ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_module_make_resident              (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);</pre>
<p>
Ensures that a module will never be unloaded.
Any future <a class="link" href="glib-Dynamic-Loading-of-Modules.html#g-module-close" title="g_module_close ()"><code class="function">g_module_close()</code></a> calls on the module will be ignored.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> to make permanently resident.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-close"></a><h3>g_module_close ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_module_close                      (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);</pre>
<p>
Closes a module.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> to close.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> on success.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-module-error"></a><h3>g_module_error ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *          g_module_error                   (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Gets a string describing the last module error.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a string describing the last module error.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GModuleCheckInit"></a><h3>GModuleCheckInit ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *       (*GModuleCheckInit)                 (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);</pre>
<p>
Specifies the type of the module initialization function.

If a module contains a function named <code class="function">g_module_check_init()</code> it is called
automatically when the module is loaded. It is passed the <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> structure
and should return <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> on success or a string describing the initialization
error.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
<td>the <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> corresponding to the module which has just been loaded.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> on success, or a string describing the initialization error.</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="GModuleUnload"></a><h3>GModuleUnload ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                (*GModuleUnload)                    (<em class="parameter"><code><a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> *module</code></em>);</pre>
<p>

Specifies the type of the module function called when it is unloaded.
If a module contains a function named <code class="function">g_module_unload()</code> it is called
automatically when the module is unloaded.
It is passed the <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> structure.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>module</code></em> :</span></p></td>
<td>the <a class="link" href="glib-Dynamic-Loading-of-Modules.html#GModule" title="GModule"><span class="type">GModule</span></a> about to be unloaded.</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="G-MODULE-SUFFIX:CAPS"></a><h3>G_MODULE_SUFFIX</h3>
<pre class="programlisting">#define G_MODULE_SUFFIX "so"
</pre>
<p>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HP-UX versions this is "sl" and for Windows this is "dll".
</p>
</div>
<hr>
<div class="refsect2">
<a name="G-MODULE-EXPORT:CAPS"></a><h3>G_MODULE_EXPORT</h3>
<pre class="programlisting">#  define G_MODULE_EXPORT		__declspec(dllexport)
</pre>
<p>
Used to declare functions exported by modules. This is a no-op on Linux and
Unices, but when compiling for Windows, it marks a symbol to be exported from
the library or executable being built.
</p>
</div>
<hr>
<div class="refsect2">
<a name="G-MODULE-IMPORT:CAPS"></a><h3>G_MODULE_IMPORT</h3>
<pre class="programlisting">#define G_MODULE_IMPORT		extern
</pre>
<p>
Used to declare functions imported from modules.
</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>